package com.wc.alorithm.string.AC;

import java.io.*;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @Author congege
 * @Description AC自动机
 * @Date Created in 2023/12/4-18:45
 */
public class Main {
    static int N = (int) 1e6 + 10;
    // 孩子节点
    static int[][] son = new int[N][26];
    // 串的个数
    static int[] cnt = new int[N];
    // 失配指针
    static int[] fail = new int[N];
    // 编号
    static int idx = 0;

    static Queue<Integer> queue = new LinkedList<>();

    static void insert(String word) {
        int p = 0;
        for (char c : word.toCharArray()) {
            int u = c - 'a';
            if (son[p][u] == 0) {
                son[p][u] = ++idx;
            }
            p = son[p][u];
        }
        ++cnt[p];
    }

    /**
     * 构建
     */
    static void build() {
        int p = 0;
        for (int i = 0; i < 26; i++) {
            if (son[p][i] != 0) {
                queue.add(son[p][i]);
            }
        }

        while (!queue.isEmpty()) {
            p = queue.poll();
            for (int i = 0; i < 26; i++) {
                if (son[p][i] != 0) {
                    fail[son[p][i]] = son[fail[p]][i];
                    queue.add(son[p][i]);
                } else {
                    son[p][i] = son[fail[p]][i];
                }
            }
        }
    }

    static int query(String s) {
        int p = 0, res = 0;
        for (char c : s.toCharArray()) {
            int u = c - 'a';
            p = son[p][u];
            for (int i = p; i > 0; i = fail[i]) {
                res += cnt[i];
            }
        }
        return res;
    }

    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) {
        // 输入n个模式串
        int n = nextInt();
        while (n-- > 0){
            insert(nextLine());
        }
        build();
        // 输入主串
        String s = nextLine();

        System.out.println(query(s));
    }
    static int nextInt(){
        int num = 0;
        try {
            num = Integer.parseInt(reader.readLine());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return num;
    }

    static String nextLine(){
        String s = null;
        try {
            s= reader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }
}
